#include<bits/stdc++.h>
using namespace std;
int main() {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r,q,p,len;
	scanf("%lld%lld%lld\n",&n,&l,&r);
	p=l%n,q=r%n;
	len=r-l+1;
	if(len<n) {
		if(p>q)
			printf("%lld\n",n-1);
		else {
			printf("%lld\n",q);
		}
	} else
		printf("%lld\n",n-1);
	return 0;
}
